<template class="vote-list">
    <div class="wrap vote-list">
        <div class="wrap-header">
            <el-carousel indicator-position="outside">
                <el-carousel-item v-for="item in imgList" :key="item.id">
                    <div class="img-center ">
                        <img :src="item.url">
                    </div>
                </el-carousel-item>
            </el-carousel>

            <el-table :data="voteList" style="width: 100%">
                <el-table-column
                    width="480"
                    prop="activityTitle"
                    label="标题">
                </el-table-column>
                <el-table-column
                    prop="deadline"
                    label="截止日期">
                </el-table-column>
                <el-table-column
                    prop="award"
                    label="奖励">
                </el-table-column>
                <el-table-column
                    fixed="right"
                    label="操作"
                    width="100">
                    <template slot-scope="scope">
                        <el-button @click="toVote(scope.row)" type="text" size="small">查看</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>


        <div class="wrap-cont">
            <div class="wrap-cont-cover">
                <div class="font-bold font-bigger">最热文章</div>
                <div class="card">
                    <div v-for="item in amwayList" class="card-item" @click="toAmway(item.shareProductionId)">
                        <img
                            :src="baseURL+item.images">
                        <div class="clearfix card-font">{{item.title}} <i class="el-icon-star-on primary ml8">{{item.likeCount}}</i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script type="text/javascript">
    import {baseURL} from "../../utils/axios";

    export default {
        name: "list",
        data() {
            return {
                currentDate: '2018-12-13',
                imgList: [{
                    id: 0,
                    url: 'http://img.idol001.com/origin/2019/04/09/41c81641206093e78a7ca05299b4fa4e1554776763.png'
                }, {
                    id: 1,
                    url: 'https://qimage.owhat.cn/prod/recommendmodule/notice/image/1554695370936.jpg'
                }, {
                    id: 2,
                    url: 'https://qimage.owhat.cn/prod/shop/cover/1554370522074.png?imageMogr2/auto-orient/thumbnail/!750x480r/gravity/Center/quality/80/crop/750x480'
                },{
                    id: 3,
                    url: 'http://img.idol001.com/origin/2019/04/08/fd1e9162622c6b51ebad0258facf1a151554718671.jpg'
                },{
                    id: 4,
                    url: 'https://qimage.owhat.cn/prod/special/cover/1554374102159.jpg?imageMogr2/auto-orient/thumbnail/!750x480r/gravity/Center/quality/80/crop/750x480'
                }],
                voteList: [],
                amwayList:[],
                baseURL:baseURL
            }
        },
        methods: {
            toVote(row) {
                this.$router.push({name: 'voteDetail', params: {title: row.activityTitle, id: row.activityId}})
            },
            toAmway(id) {
                this.$router.push({name: 'amwayDetail', query: {id: id}})
            },
            getVoteList() {
                this.$api.vote.voteList({
                    "pageNum": 1,
                    "pageSize": 100
                }).then(res => {
                    this.voteList = res.data.list;
                })
            },
            getAmwayList() {
                this.$api.amway.getAmwayList(
                    {
                        pageNum: 1,
                        pageSize: 100
                    }
                ).then(res => {
                    this.amwayList = res.data.list;
                })
            }
        },
        mounted() {
            setTimeout(() => {
                this.$eventBus.emit('updateTitle', '推荐')
            });
            this.getVoteList();
            this.getAmwayList();
        }
    }
</script>

<style rel="stylesheet/scss" lang="scss">
    .vote-list {
        .time {
            font-size: 13px;
            color: #999;
        }

        .primary {
            color: $text-color-primary;
        }

        .bottom {
            margin-top: 8px;
            display: flex;
            justify-content: space-between;
        }

        .button {
            padding: 0;
            float: right;
        }

        .image {
            width: 100%;
            display: block;
        }

        .clearfix:before,
        .clearfix:after {
            display: table;
            content: "";
        }

        .clearfix:after {
            clear: both
        }

        .el-carousel__item h3 {
            color: #475669;
            font-size: 18px;
            opacity: 0.75;
            line-height: 300px;
            margin: 0;
        }

        .el-carousel__item:nth-child(2n) {
            background-color: #99a9bf;
        }

        .el-carousel__item:nth-child(2n+1) {
            background-color: #d3dce6;
        }


        .img-center {
            text-align: center;
            img{
                height: 350px;
                max-width: fit-content;
            }
        }
        .card {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;

            &-item {
                margin: 4px;
                border-radius: 4px;
                border: 1px solid #ebeef5;
                background-color: #fff;
                overflow: hidden;
                color: #303133;
                -webkit-transition: 0.3s;
                transition: 0.3s;
                padding-left: 6px;
                padding-right: 6px;
                width: 18%;
                text-align: center;
            }

            &-font {
                font-size: 14px;
            }
            img {
                height: 140px;
            }
        }
    }

</style>
